home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / MUBBS etc.cpt / Module Source / E-mail / CheckEmail.c next >
Text File  |  1991-11-21  |  4KB  |  143 lines

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        CheckEmail Module
  4.       
  5.      DESCRIPTION:    This CheckEmail Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.      10/20/91 - Started programming
  19.      11/ 4/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25. #define        INMAIN
  26.  
  27.  
  28. #include    "MUBBS Module.h"
  29. #include    "Email.h"
  30. #include    <SetUpA4.h>
  31.  
  32.  
  33. pascal void main (mode1,G1,P1)
  34.        int mode1;
  35.        struct GS *G1;
  36.        Ptr P1;  
  37. {
  38. Handle temph;
  39. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  40. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  41. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  42.  
  43. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  44. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  45.  
  46.  
  47. switch (mode[u]) { /* any un-handled modes return error from this module */
  48.     case 3:
  49.         findemail(P1); /* mode 3 because we are passing a user pointer */
  50.         G->moduleresult=0;
  51.         break;
  52.     case 98:
  53.         versionck(version); /* just return after this call, don't modify anything */
  54.         break;        
  55.     case 0:
  56.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  57.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  58.         break;
  59.     default:
  60.         G->moduleresult=1; /* return bad code */
  61.     };
  62.  
  63. HUnlock(temph); /* unlocks this module, do this ! */
  64. RestoreA4(); /* call this when you are all done */
  65. }
  66.  
  67.  
  68. findemail(S)
  69. struct LoadStruct *S;
  70. {
  71. char pad[100]; /* this is a fix for a problem */
  72. struct MsgStruct MsgInfo;
  73. int a, num, numemail, count;
  74. FILE *fp_headers;
  75. long int temp;
  76. char tempc[maxnamelength];
  77.  
  78. if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
  79.  
  80.  
  81. if ( (fp_headers = fopen(":msgs:email.headers","r")) == NULL )
  82.     {
  83.     send("]Can't open the file: %s]]",":msgs:email.headers");
  84.     num = 3;
  85.     }
  86. else
  87.     {
  88.     count=0;
  89.     a = 0;
  90.     num = 0;
  91.     numemail=0;
  92.     while (a == 0)
  93.         {    
  94.         temp = ftell(fp_headers);
  95.         fread( MsgInfo.FromUser, sizeof(MsgInfo),1,fp_headers);    
  96.         if (feof(fp_headers) == 0)
  97.             {
  98.             if ( numemail < MAXEMAIL )
  99.                 {
  100.                 strtoupper(MsgInfo.ToUser);
  101.                 strcpy(tempc,G->username[u]); /* check the name uppercased! */
  102.                 strtoupper(tempc);
  103.                 if (strcmp(MsgInfo.ToUser,tempc) == 0)
  104.                 if (MsgInfo.status != DELETED )
  105.                     {
  106.                     numemail = numemail+1;
  107.                     S->i_headers[numemail] = temp;
  108.                     strcpy( S->FromUser[numemail] , MsgInfo.FromUser );
  109.                     strcpy( S->title[numemail] , MsgInfo.title );
  110.                     S->status[numemail] = MsgInfo.status;
  111.                     strcpy( S->NetAddress[numemail] , MsgInfo.NetAddress);
  112.                     S->offset[numemail] = MsgInfo.offset;
  113.                     S->length[numemail] = MsgInfo.length;
  114.                     strcpy( S->DateSent[numemail] , MsgInfo.DateSent);
  115.                     }
  116.                 }
  117.             else
  118.                 {
  119.                 a = 1;    /* More than MAXEMAIL msgs */
  120.                 num = 20;
  121.                 }
  122.             }
  123.         else
  124.             {
  125.             a = 1; /* ran into EOF */
  126.             num = 0;
  127.             }
  128.         if ((++count % 10) == 0) {sendnc (".");} /* show dots */
  129.         }
  130.     fclose(fp_headers); /* close that file ! */
  131.     }
  132. if(numemail <1 && num == 0)
  133.     {
  134.     num = 21;  /* No email found */
  135.     }
  136.  
  137. S->numemail = numemail;
  138. byebye:
  139. S->result = num;
  140. return;
  141. }
  142.  
  143.